<?php
//$q=$_GET["q"];

//$con = mssql_connect('localhost', 'peter', 'abc123');
//$con = mssql_connect('AUQLDVA0', 'sa', 'sa-auqldva0');
//$con = mssql_connect('AKERNST\AKERNST', 'sa', 'andree1');
//$con = mssql_connect('localhost', 'sa', 'andree1');
//$con = mssql_connect('', 'sa', 'andree1');



$intSkipCount = 0;
$intTotalPages = 0;
//Change next line for page size
$intPageSize = 8;
//
$intCurrentPage = 0;
$intTotalNoRecords = 0;
$intRowID = 0;
$strSortField = "";
$strInnerAction = "";
$strAction = "";
$strpageload = "";
$strDispTotals = "";
$strDispPageCounts = "";
$strDispPKID = "";
$strDispPKIDNEW = "";
$strDataTable = "";
$strHeaderTable = "";
//$strNavTable = "";
$strbtnLastPage = "";
$strbtnFirstPage = "";
$strbtnPreviousPage = "";
$strbtnNextPage = "";
$strlblCurrentPage = "";
$strarraysearch = "";
$strmachsearch = "";
$strPKID = "";
$strPKIDNEW = "";
$strDispSEARCH = "";
$strchkresetcriteria = "";
$strarraysearch2 = "";
$strDoSort = "";
$strSortDirection = "";
$strDispSortDirection = "";
    



$strAction = $_REQUEST["action"];           //get action from another web page

$strDoSort = $_REQUEST["dosort"];    

//echo "OK";
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
//Add Search criteria, or comment out if not using search criteria (can leave in)
  $strarraysearch = $_REQUEST["textsearch"];
//if ($strarraysearch == null
  if ($strarraysearch == ""
            || strlen($strarraysearch) == 0)
  {
            //nothing
  }
  else
  {
             $strarraysearch = $strarraysearch;
            //$strarraysearch = $strarraysearch.Replace("'", "''");                     //so as to cope with any Apostrophes in text
  }

  //$strmachsearch = $_REQUEST["dropdownsearch"];
  //if ($strmachsearch == ""
  //          || strlen($strmachsearch) == 0)
  //{
            //nothing
  //}
  //else
  //{
  //           $strmachsearch = $strmachsearch;
            //$strmachsearch = $strmachsearch.Replace("'", "''");                     //so as to cope with any Apostrophes in text
  //}
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&



        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //Get Total Page count and Total Record count, to store hidden on Page
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        $intTotalNoRecords = Get_Total_Records();

        $intTotalPages = ($intTotalNoRecords / $intPageSize);
        //Adjust the page count if the last page contains a partial page.
        if (($intTotalNoRecords % $intPageSize) > 0)
        {
            $intTotalPages = ($intTotalPages + 1);
        }

        //STORE Total HIDDEN values ready to display
        $strDispTotals = DispTotalInfo($intTotalPages, $intTotalNoRecords);
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        //END Get Total Page count and Total Record count
        //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


//echo "After Count OK";
//echo $intTotalNoRecords;
//echo $intTotalPages;
//echo $strDispTotals;



        if (($intTotalNoRecords > 0))
        {
            switch ($strAction)
            {
                case "firstpage":
                    //echo "in firstpage";
                    $intCurrentPage = $_REQUEST["pageid"];
                    $intRowID = 0;
                    $intSkipCount = 0;
                    $strSortField = $_REQUEST["sortby"];
                    // STORE Page Counts HIDDEN values ready to display
                    $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                    DisplayFirstPage();
                    //echo "in firstpage2";
                    break;
                case "nextpage":
                    if ((($intCurrentPage == $intTotalPages)
                                || ($_REQUEST["pageid"] == $intTotalPages)))
                    {
                        $intRowID = 0;
                        $intSkipCount = (($intTotalPages - 1) * $intPageSize);
                        $intCurrentPage = $intTotalPages;
                        $strSortField = $_REQUEST["sortby"];
                        // Sorting by   
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        NextPage();
                    }
                    else
                    {
                        $intCurrentPage = ($_REQUEST["pageid"] + 1);
                        $intRowID = 0;
                        $strSortField = $_REQUEST["sortby"];
                        // Workout SkipCount of records, for next page
                        $intSkipCount = ($_REQUEST["skip"] + $intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        NextPage();
                    }
                    break;
                case "prevpage":
                    if ((($intCurrentPage == 1)
                                || ($_REQUEST["pageid"] == 1)))
                    {
                        $intRowID = 0;
                        $intSkipCount = 0;
                        $intCurrentPage = 1;
                        $strSortField = $_REQUEST["sortby"];
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        DisplayFirstPage();
                    }
                    else
                    {
                        $intCurrentPage = ($_REQUEST["pageid"] - 1);
                        $intRowID = 0;
                        $strSortField = $_REQUEST["sortby"];
                        $intSkipCount = ($_REQUEST["skip"] - $intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo(intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        PrevPage();
                    }
                    break;
                case "lastpage":
                    if ((($intCurrentPage == $intTotalPages)
                                || ($_REQUEST["pageid"] == $intTotalPages)))
                    {
                        $intRowID = 0;
                        $intSkipCount = (($intTotalPages - 1) * $intPageSize);
                        $intCurrentPage = $intTotalPages;
                        $strSortField = $_REQUEST["sortby"];
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        NextPage();
                      
                    }
                    else
                    {
                        $intCurrentPage = $intTotalPages;
                        $intRowID = 0;
                        $strSortField = $_REQUEST["sortby"];
                        $intSkipCount = (($intTotalPages - 1) * $intPageSize);
                        // STORE Page Counts HIDDEN values ready to display
                        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                        NextPage();
                    }
                    break;
                case "pageid":
                    $intCurrentPage = $_REQUEST["pageid"];
                    $intRowID = 0;
                    $strSortField = $_REQUEST["sortby"];
                    $intSkipCount = (($intCurrentPage * $intPageSize) - $intPageSize);
                    // STORE Page Counts HIDDEN values ready to display
                    $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                    NextPage();
                    break;
                case "GetCurrentPage":
                    $strchkresetcriteria = $_REQUEST["chkresetcriteria"];
                    // use to check if Search Criteria field have changed
                    $strPKIDNEW = $_REQUEST["num"];
                    $intCurrentPage = $_REQUEST["pageid"];
                    $intRowID = $_REQUEST["rowid"];
                    $strSortField = $_REQUEST["sortby"];
                    $intSkipCount = $_REQUEST["skip"];
                    $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                    NextPage();
                    $strDispPKID = DispPKIDInfo($strPKIDNEW);
                    break;
                default:
                    $intSkipCount = 0;
                    $intCurrentPage = 1;
                    $intRowID = 0;
                    // STORE Page Counts HIDDEN values ready to display
                    $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
                    DisplayFirstPage();
                    break;
            }

            // DISPLAY OUTPUT to go BACK (to innerHTML of Requested Page)
            //echo $strHeaderTable;
            //echo $strDataTable;
            //echo "about display nav";
            echo $strNavTable;
            //echo $strDispPKID;
            $strDispSEARCH = DispSEARCHInfo($strchkresetcriteria);
            //echo $strDispSEARCH;
            echo $strDispPageCounts;
            echo $strDispTotals;
            //echo $strDispSortDirection;

            // *************************************************************************************************************************************************************
            // This next Part is for writing out to a HTML page so as to see Layout Design
            // USED ONLY FOR TESTING
            //string FILENAME = Server.MapPath("Output.html");
            //StreamWriter objStreamWriter;
            //objStreamWriter = File.AppendText(FILENAME);
            //objStreamWriter.WriteLine(strNavTable);
            //objStreamWriter.WriteLine(strHeaderTable);
            //objStreamWriter.WriteLine(strDataTable);
            //objStreamWriter.Close();
            // *************************************************************************************************************************************************************
        }
        else
        {
            // No records found
            $intSkipCount = 0;
            $intCurrentPage = 1;
            $intRowID = 0;
            $strNavTable = "";
            $strHeaderTable = "";
            GetHeaderTable();
            $strDataTable = "";
            $strDispPKID = "";
            $strDispSEARCH = "";
            $strDispPageCounts = "";
            $strDispTotals = "";

            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
            //Change next line to Sort default as in ARRAYS_LIST.aspx
            $strSortField = "PK_ID";
            //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

            $strchkresetcriteria = "No Records";
            $strDispSEARCH = DispSEARCHInfo($strchkresetcriteria);
            $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);
            $strPKIDNEW = "0";
            $strDispPKID = DispPKIDInfo($strPKIDNEW);
            echo $strDispPageCounts;
            echo $strDispTotals;
            echo $strDispSortDirection;
            echo $strDispSEARCH;
            // echo $strHeaderTable;    'Optional taking out Header display
            echo $strDispPKID;
        }
        // If intTotalNoRecords > 0

    //}






    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    //These next 5 Functions are used to keep internal variables, and so are MANDATORY
    // NOTE:-  Can change type=hidden  -->   type=text, for displaying variables below
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    function DispTotalInfo($TotalPages, $TotalNoRecords)
    {
        $cRet;
        $cRet = "";
        $cRet = $cRet . "<input name='TotalPages' id='TotalPages' type='text' value='" . $TotalPages . "' />" . "\r\n";      
        $cRet = $cRet . "<input name='TotalNoRecords' id='TotalNoRecords' type='text' value='" . $TotalNoRecords . "' />" . "\r\n";
        return $cRet;
    }

    function DispPageCountInfo($PageSize, $CurrentPage, $RowID, $SkipCount, $SortField)
    {
        $cRet;
        $cRet = "";
        $cRet = $cRet . "<input name='CurrentPageGet' id='CurrentPageGet' type='hidden' value='" . $CurrentPage . "' />" . "\r\n";
        $cRet = $cRet . "<input name='RowIDGet' id='RowIDGet' type='hidden' value='" . $RowID . "' />" . "\r\n";
        $cRet = $cRet . "<input name='SkipCount' id='SkipCount' type='hidden' value='" . $SkipCount . "' />" . "\r\n";
        $cRet = $cRet . "<input name='PageSizeGet' id='PageSizeGet' type='hidden' value='" . $PageSize . "' />" . "\r\n";
        $cRet = $cRet . "<input name='SortFieldGet' id='SortFieldGet' type='text' value='" . $SortField . "' />" . "\r\n";
        return $cRet;
    }

    function DispPKIDInfo($PKID)
    {
        $cRet;
        $cRet = "";
        $cRet = $cRet . "<input name='textcurrentpkid' id='textcurrentpkid' type='hidden' value='"
                    . $PKID . "' />" . "\r\n";
        return $cRet;
    }

    function DispSEARCHInfo($chkresetcriteria)
    {
        $cRet;
        $cRet = "";
        $cRet = $cRet . "<input name='chkresetcriteria' id='chkresetcriteria' type='hidden' value='"
                    . $chkresetcriteria . "' />" . "\r\n";
        return $cRet;
    }
    
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------
    // END of 5 Functions are used to keep internal variables, and so are MANDATORY
    //--------------------------------------------------------------------------------------------------------------------------------------------------------------







    function Get_Total_Records()
    {
        // ------------------------------------------------------------------------------------------- 
        $intwherecounter = 0;
        $intCounter = 0;
        //SqlCommand objCmd;
        $strSQL = "";
         
        $dsn2="SQLSERVER2005";
        $username2="sa";
        $password2="andree1";

        $sqlconnect2=odbc_connect($dsn2,$username2,$password2);


        //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
        $strSQL = "SELECT top 10 PK_ID from ARRAYS2 ";
        $intwherecounter = 0;
        if ($strarraysearch == ""
                    || (strlen($strarraysearch) == 0))
        {
            // nothing to Search
        }
        else
        {
            // NOTE:- To make faster, put % only at end
            $strSQL = $strSQL . " WHERE Array_Name like '%"
                        . $strarraysearch . "%'";
            $intwherecounter = 1;
        }

        if ($strmachsearch == ""
                    || (strlen($strmachsearch) == 0))
        {
            // nothing to Search
        }
        else if (($intwherecounter == 1))
        {
            $strSQL = ($strSQL . (" AND ~dropdownsearch~ = '"
                        . ($strmachsearch . "'")));
        }
        else
        {
            $strSQL = $strSQL . " WHERE ~dropdownsearch~ = '"
                        . $strmachsearch . "'";
        }
        // &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

        //echo $strSQL;

        $rs=odbc_exec($sqlconnect2, $strSQL);
        if (!$rs)
         {
            echo "error in Connecting to do Count";
         }

         while (odbc_fetch_row($rs))
         {
            //$intCounter = $rs[0];
            $intCounter = $intCounter + 1;
         }

        odbc_close($sqlconnect2);

         //echo $intCounter;

        return $intCounter;

    }




    function DisplayFirstPage()
    {
        //echo "in Displayfirstpage";
        // ------------------------------------------------------------------------------------------- 
        // echo "in First Page . "<br>";
        // STORE Page Counts HIDDEN values ready to display
        $strDispPageCounts = DispPageCountInfo($intPageSize, $intCurrentPage, $intRowID, $intSkipCount, $strSortField);

        //GetPageOfRecords();          // global subroutine
        //GetHeaderTable();

        //strbtnPreviousPage = "disabled='disabled'";
        //strbtnFirstPage = "disabled='disabled'";
        $strbtnPreviousPage = "hidden";
        $strbtnFirstPage = "hidden";
        $strbtnNextPage = "";
        $strbtnLastPage = "";

        DisplayPageInfo();               // global subroutine
        $strNavTable2 = GetNavigationTable();
        echo $strNavTable2;
    }



    function NextPage()
    {
        // ------------------------------------------------------------------------------------------- 
        // response.write("in Next Page & "<br>"")
        // Check if on First Page
        if (($intCurrentPage == 1))
        {
            // at first page
            DisplayFirstPage();
            //return;
        }
        else
        {
         GetPageOfRecords();
         // global subroutine
         GetHeaderTable();
         if (($intCurrentPage == $intTotalPages))
         {
            // at last page
            $strbtnNextPage = "hidden";
            $strbtnLastPage = "hidden";
            $strbtnPreviousPage = "";
            $strbtnFirstPage = "";
         }
         else
         {
            $strbtnNextPage = "";
            $strbtnLastPage = "";
            $strbtnPreviousPage = "";
            $strbtnFirstPage = "";
         }
         DisplayPageInfo();

         // global subroutine
         GetNavigationTable();
        }

    }


    function PrevPage()
    {
        // ------------------------------------------------------------------------------------------- 
        // response.write("in Previous Page & "<br>"")
        // Check if on First Page
        if (($intCurrentPage == 1))
        {
            // at first page
            DisplayFirstPage();
            //return;
        }
        else
        {
         GetPageOfRecords();
         // global subroutine
         GetHeaderTable();

         $strbtnPreviousPage = "";
         $strbtnFirstPage = "";
         $strbtnNextPage = "";
         $strbtnLastPage = "";
         DisplayPageInfo();
         // global subroutine
         GetNavigationTable();
        }

    }


    function DisplayPageInfo()
    {
         //echo "in DisplayPageInfo";
        //  This displays (eg Page 1 of 23     Total Records:  457)  on top of navigation buttons
        //  Can be modified to suit
        // --------------------------------------------------------------------------------------------------------------------------------------------------------------
        if ((($intTotalPages == 1)
                    || ($intTotalPages == 0)))
        {
            $strbtnNextPage = "hidden";
            $strbtnLastPage = "hidden";
            $strbtnPreviousPage = "hidden";
            $strbtnFirstPage = "hidden";
        }

        $strlblCurrentPage = "";
        $strlblCurrentPage = "Page: " . $intCurrentPage . "  of  " . $intTotalPages .
                              "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" .
                              "" . $intTotalNoRecords . " Records"; 

    }


    function GetNavigationTable()
    {
        //echo "in GetNavigationTable";
        //  This displays navigation buttons (ie First Page, Next, Prev, Last Page)
        //  Can be modified to suit
        // -------------------------------------------------------------------------------------------------------------------------------------------------------------
        //Response.Write(("in GetNavigationTable " + "<br>\""));
        $intPageCnt = 0;
        $strNavTable = "";

        $strNavTable = $strNavTable . "<div" . "\r\n";
        $strNavTable = $strNavTable . " style='BORDER-TOP: 1px solid white;" . "\r\n";
        $strNavTable = $strNavTable . " BORDER-BOTTOM: 1px solid white;" . "\r\n";
        $strNavTable = $strNavTable . " BORDER-LEFT: 1px solid white;" . "\r\n";
        $strNavTable = $strNavTable . " BORDER-RIGHT: 1px solid white'>" . "\r\n";
        $strNavTable = $strNavTable . "</div>" . "\r\n";

        //echo $strNavTable;

        $strNavTable = $strNavTable . "<table id='myNav' border='0' bgcolor='#006699' bordercolor='gray' cellspacing='0' cellpadding='0'  width='682" . "px'>" . "\r\n";
        //$strNavTable = $strNavTable . "<tr>" . "\r\n";
        //$strNavTable = $strNavTable . "<td>" . "\r\n";
        // $strNavTable = $strNavTable . " " . "\r\n";
        //$strNavTable = $strNavTable . "</td>" . "\r\n";
        //$strNavTable = $strNavTable . "</tr>" . "\r\n";
        //$strNavTable = $strNavTable . "<tr>" . "\r\n";
        //$strNavTable = $strNavTable . "<td>" . "\r\n";
        //$strNavTable = $strNavTable . "<span id=\'lblMessage\' tabindex=\'-1\'></span>" . "\r\n";
        //$strNavTable = $strNavTable . "</td>" . "\r\n";
        //$strNavTable = $strNavTable . "</tr>" . "\r\n";
        $strNavTable = $strNavTable . "<tr>" . "\r\n";
        $strNavTable = $strNavTable . "<td width='240px' " . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 2px';" . "\r\n";
        $strNavTable = $strNavTable . " BORDER-RIGHT: 1px solid gray'>" . "\r\n";
        
        $strNavTable = $strNavTable . "<span id='lblCurrentPage' tabindex='-1'>" . $strlblCurrentPage . "</span>" . "\r\n";
        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "<td align='right' width=10px" . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 0px'>" . "\r\n";
        
        //echo $strNavTable;

        // ............................................................................................................................................................................................................................................
        // FIRST PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //$strNavTable = $strNavTable . "<input type=\'submit\' name=\'btnFirstPage\' value=\'<<\' id=\'btnFirstPage\' " . $strbtnFirstPage . " tabindex=\'-1\' " . "\r\n";
        //$strNavTable = $strNavTable . " onclick=\'javascript: initload" . '"' . $strSortField . '"' . ";return false;\' " . " />" . "\r\n";
        if ($strbtnFirstPage != "hidden")
        {
            $strNavTable = $strNavTable . "<a id='navigat' href='javascript: FirstPageit" . '"' . $strSortField . '"' . ";'>" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/FIRST_09.gif\' ALT=\'First Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'22\' HEIGHT=\'20\' border=\'0\'>" . "\r\n";
            // $strNavTable = $strNavTable . " <img SRC=\'images/FIRST_10.gif\' ALT=\'First Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'23\' HEIGHT=\'25\' border=\'0\'>" . "\r\n";
            $strNavTable = $strNavTable . " << " . "\r\n";

            $strNavTable = $strNavTable . " </a>" . " " . "\r\n";
        }
        
        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "<td width=16px" . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 0px'>" . "\r\n";
        
        // ............................................................................................................................................................................................................................................
        // PREVIOUS PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //$strNavTable = $strNavTable . "<input type=\'submit\' name=\'btnPreviousPage\' value=\'<\' id=\'btnPreviousPage\' " . $strbtnPreviousPage . " tabindex=\'-1\' " . "\r\n";
        //$strNavTable = $strNavTable . " onclick=\'javascript: PrevPageit" . '"' . intCurrentPage . '"' . ",";
        //$strNavTable = $strNavTable . '"' . $strSortField . '"' . ",";
        //$strNavTable = $strNavTable . '"' . $intSkipCount . '"' . ";return false;\' " . " />" . "\r\n";
        if ($strbtnPreviousPage != "hidden")
        {
            $strNavTable = $strNavTable . "<a id='navigat' href='javascript: PrevPageit" . '"' . $intCurrentPage . '"' . ",";
            $strNavTable = $strNavTable . '"' . $strSortField . '"' . ",";
            $strNavTable = $strNavTable . '"' . $intSkipCount . '"' . ";\' " . " >" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/PREV_09.gif\' ALT=\'Previous Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'17\' HEIGHT=\'20\' border=\'0\'>" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/PREV_10.gif\' ALT=\'Previous Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'15\' HEIGHT=\'25\' border=\'0\'>" . "\r\n";
            $strNavTable = $strNavTable . " Prev " . "\r\n";
            $strNavTable = $strNavTable . " </a>" . " " . "\r\n";
        }
        
        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "<td width=16px" . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 0px'>" . "\r\n";
        
        // ............................................................................................................................................................................................................................................
        // NEXT PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //$strNavTable = $strNavTable . "<input type=\'submit\' name=\'btnNextPage\' value=\'>\' id=\'btnNextPage\' " . $strbtnNextPage . " tabindex=\'-1\' " . "\r\n";
        //$strNavTable = $strNavTable . " onclick=\'javascript: NextPageit" . '"' . $intCurrentPage . '"' . ",";
        //$strNavTable = $strNavTable . '"' . $strSortField . '"' . ",";
        //$strNavTable = $strNavTable . '"' . $intSkipCount . '"' . ";return false;\' " . " />" . "\r\n";
        if ($strbtnNextPage != "hidden")
        {
            $strNavTable = $strNavTable . "<a id='navigat' href='javascript: NextPageit" . '"' . $intCurrentPage . '"' . ",";
            $strNavTable = $strNavTable . '"' . $strSortField . '"' . ",";
            $strNavTable = $strNavTable . '"' . $intSkipCount . '"' . ";\' " . " >" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/NEXT_09.gif\' ALT=\'Next Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'17\' HEIGHT=\'20\' border=\'0\'>" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/NEXT_10.gif\' ALT=\'Next Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'15\' HEIGHT=\'25\' border=\'0\'>" . "\r\n";
            $strNavTable = $strNavTable . " Next " . "\r\n";
            $strNavTable = $strNavTable . " </a>" . " " . "\r\n";
        }
        
        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "<td width=1px" . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 0px'>" . "\r\n";
        
        // ............................................................................................................................................................................................................................................
        // LAST PAGE Button
        // ............................................................................................................................................................................................................................................
        // Note:- Non image button alternative commented out
        //$strNavTable = $strNavTable . "<input type=\'submit\' name=\'btnLastPage\' value=\'>>\' id=\'btnLastPage\' " . $strbtnLastPage . " tabindex=\'-1\' " . "\r\n";
        //$strNavTable = $strNavTable . " onclick=\'javascript: LastPageit" . '"' . $intCurrentPage . '"' . ",";
        //$strNavTable = $strNavTable . '"' . strSortField . '"' . ",";
        //$strNavTable = $strNavTable . '"' . intSkipCount . '"' . ";return false;\' " . " />" . "\r\n";
        if ($strbtnLastPage != "hidden")
        {
            $strNavTable = $strNavTable . "<a id='navigat' href='javascript: LastPageit" . '"' . $intCurrentPage . '"' . ",";
            $strNavTable = $strNavTable . '"' . $strSortField . '"' . ",";
            $strNavTable = $strNavTable . '"' . $intSkipCount . '"' . ";\' " . " >" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/LAST_09.gif\' ALT=\'Last Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'21\' HEIGHT=\'20\' border=\'0\'>" . "\r\n";
            //$strNavTable = $strNavTable . " <img SRC=\'images/LAST_10.gif\' ALT=\'Last Page\' " . "\r\n";
            //$strNavTable = $strNavTable . "  WIDTH=\'23\' HEIGHT=\'25\' border=\'0\'>" . "\r\n";
            $strNavTable = $strNavTable . " >> " . "\r\n";
            $strNavTable = $strNavTable . " </a> " . "\r\n";
        }

        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "<td width=282px" . "\r\n";
        $strNavTable = $strNavTable . " style='FONT-SIZE: 12px;" . "\r\n";
        $strNavTable = $strNavTable . " FONT-FAMILY: Arial;" . "\r\n";
        $strNavTable = $strNavTable . " COLOR: white;" . "\r\n";
        $strNavTable = $strNavTable . " PADDING: 0px'>" . "\r\n";
        
        
        //echo $strNavTable;

        //for intPageCnt = 1; intPageCnt <= intTotalPages; intPageCnt..
        //{
            //if intPageCnt == 1
            //{
            //    //$strNavTable = $strNavTable . " " . "<a id=\'LinkButton1\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "1" . '"' . "," . '"' 
                //            . strSortField . '"' . "\'>1</a> " . " ";
            //}
            //if intPageCnt == 2
           //{
                //$strNavTable = $strNavTable . "<a id=\'LinkButton2\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "2" . '"' . "," . '"' 
            //              . strSortField . '"' . "\'>2</a> " . " ";
            //}
            //if intPageCnt == 3
            //{
                //$strNavTable = $strNavTable . "<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "3" . '"' . "," . '"' 
                //            . strSortField . '"' . "\'>3</a> " . " ";
            //}
            //if intPageCnt == 4
            //{
                // $strNavTable = $strNavTable . "<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "4" . '"' . "," . '"' 
                //              . strSortField . '"' . "\'>4</a> " . " ";
            //}
            //if intPageCnt == 5
            //{
                // $strNavTable = $strNavTable . "<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "5" . '"' . "," . '"' 
                //          . strSortField . '"' . "\'>5</a> " . " ";
           //}
            //if intPageCnt == 6
            //{
                // $strNavTable = $strNavTable . "<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "6" . '"' . "," . '"' 
                //           . strSortField . '"' . "\'>6</a> " . " ";
           // }
        //}


        //$strNavTable = $strNavTable . "<a id=\'LinkButton1\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "1" . '"' . "," . '"' . strSortField . '"' . "\'>1</a> " . " ";
        //$strNavTable = $strNavTable . "<a id=\'LinkButton2\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "2" . '"' . "," . '"' . strSortField . '"' . "\'>2</a> " . " ";
        //$strNavTable = $strNavTable . "<a id=\'LinkButton3\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "3" . '"' . "," . '"' . strSortField . '"' . "\'>3</a> " . " ";
        //$strNavTable = $strNavTable . "<a id=\'LinkButton4\' tabindex=\'-1\' href=\'javascript:PageID" . '"' . "4" . '"' . "," . '"' . strSortField . '"' . "\'>4</a> " . " ";

        $strNavTable = $strNavTable . "</td>" . "\r\n";
        $strNavTable = $strNavTable . "</tr>" . "\r\n";
        $strNavTable = $strNavTable . "</table>" . "\r\n";

        //echo $strNavTable;
        return $strNavTable;
    }







//===================================================================================================================
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

$dsn="SQLSERVER2005";
$username="sa";
$password="andree1";

$sqlconnect=odbc_connect($dsn,$username,$password);
$sqlquery="SELECT top 10 Array_Name, Loaded_Machine, Start_Date, PK_ID FROM ARRAYS2;";
$process=odbc_exec($sqlconnect, $sqlquery);


if (!$sqlconnect)

 {
  //echo mssql_error(); 
  echo "error in Connecting";
 //die('Could not connect: ' . mssql_error());
 }
else
{
   //echo "OK";

}



$str = "<table border='1'>
<tr>
<th>Arrayname</th>
<th>LoadedMachine</th>
<th>StartDate</th>
<th>PK_ID</th>
</tr>";

//echo "<table border='1'>
//<tr>
//<th>Arrayname</th>
//<th>LoadedMachine</th>
//<th>StartDate</th>
//<th>PK_ID</th>
//</tr>";



while(odbc_fetch_row($process))
{
 $str = $str . "<tr>";
 $str = $str . "<td>" . odbc_result($process,"Array_Name") . "</td>";

 //echo "<tr>";
 //echo "<td>" . odbc_result($process,"Array_Name") . "</td>";
 //echo "<td>" . odbc_result($process,"Loaded_Machine") . "</td>";
 //echo "<td>" . odbc_result($process,"Start_Date") . "</td>";
 //echo "<td>" . odbc_result($process,"PK_ID") . "</td>";
 //echo "</tr>";
  $str = $str . "</tr>";
 }

$str = $str . "</table>";
//echo "</table>";


//$companyName = odbc_result($process,"Array_Name");
//echo "$companyName<br>"; 
//}


echo $str;

odbc_close($sqlconnect);



?>
